<template lang="pug">
.page
  .InsuranceInfoSet
    Tabs(:name="tabName" :animated="false" @on-click="handleClickTab")
      TabPane(label="社会保险" name="shebao" v-if="checkEmployeeNum.indexOf('1') !== -1")
        BatchSetShebao
      TabPane(label="公积金" name="gongjijin" v-if="checkEmployeeNum.indexOf('2') !== -1")
        BatchSetGongjijin
      TabPane(label="商业保险" name="shangbao" v-if="checkEmployeeNum.indexOf('3') !== -1")
        BatchSetShangbao
</template>

<script>
import { FormShebaoFilter, FormShebaoFilterItem, FormShebaoTitle, FormShebao, FormShebaoItem, FormGongjijinFilter, FormGongjijinFilterItem, FormGongjijinTitle, FormGongjijin, FormGongjijinItem } from './EBformData.js'
import _cloneDeep from 'clone-deep'
import BatchSetShebao from './modal/batchSetShebao.vue' // 社会保险
import BatchSetGongjijin from './modal/batchSetGongjijin.vue' // 公积金
import BatchSetShangbao from './modal/batchSetShangbao.vue' // 商业保险

export default {
  name: 'InsuranceInfoSet',

  components: {
    BatchSetShebao,
    BatchSetGongjijin,
    BatchSetShangbao
  },

  data () {
    return {
      isOnlyView: false,
      formShebaoFilter: _cloneDeep(FormShebaoFilter),
      formShebaoFilterItem: _cloneDeep(FormShebaoFilterItem),
      formShebaoTitle: _cloneDeep(FormShebaoTitle),
      formShebao: _cloneDeep(FormShebao),
      formShebaoItem: _cloneDeep(FormShebaoItem),
      formGongjijinFilter: _cloneDeep(FormGongjijinFilter),
      formGongjijinFilterItem: _cloneDeep(FormGongjijinFilterItem),
      formGongjijinTitle: _cloneDeep(FormGongjijinTitle),
      formGongjijin: _cloneDeep(FormGongjijin),
      formGongjijinItem: _cloneDeep(FormGongjijinItem),
      rules: {},
      arrListDown: {},
      dateOptions: {},
      selectedEmployeeId: [],
      tabName: null,
      checkEmployeeNum: '1,2,3'
    }
  },

  watch: {
  },

  created () {
    this.checkEmployeeNum = this.$route.query.checkEmployeeNum
    if (this.checkEmployeeNum.indexOf('1') !== -1) {
      this.tabName = 'shebao'
    } else if (this.checkEmployeeNum.indexOf('2') !== -1) {
      this.tabName = 'gongjijin'
    } else if (this.checkEmployeeNum.indexOf('3') !== -1) {
      this.tabName = 'shangbao'
    }
    console.log('this.tabName: ' + this.tabName)
  },

  mounted () {
    this.selectedEmployeeId = JSON.parse(localStorage.getItem('selectedEmployeeId')) // 选中的员工
    console.log('🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈 this.selectedEmployeeId: ', this.selectedEmployeeId)
  },

  methods: {
    handleClickTab (name) {
      this.tabName = name
    }
  },

  destroyed () {
    // 离开页面时，移除相关缓存信息
    localStorage.removeItem('selectedEmployeeId')
  }
}
</script>

<style lang="less" scope>
.InsuranceInfoSet{

}
</style>
